package com.example.kt_base.s5

//TODO 99.Kotlin语言的密封类
sealed class Exams {
    object Eraction1 : Exams()
    object Eraction2 : Exams()
    object Eraction3 : Exams()
    class Eraction4(val studentName:String) : Exams()
}

class Teacher1(private val exam: Exams) {
    fun show() = when (exam) {
        is Exams.Eraction1-> "该学生分数很差"
        is Exams.Eraction2-> "该学生分数一般"
        is Exams.Eraction3 -> "该学生分数良好"
        is Exams.Eraction4 -> "该学生分数优秀，该学生的姓名是:${this.exam.studentName}"
        //不用else 了
    }

}

fun main() {

    println(Teacher1(Exams.Eraction3).show())
    println(Teacher1(Exams.Eraction4("lian")).show())

}
